package com.pinyoumei.app.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.pinyoumei.app.R;
import com.pinyoumei.app.network.Constants;
import com.pinyoumei.app.utils.DonwloadSaveImg;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;

/**
 * Created by Administrator on 2020-07-31.
 * --------- 日期 ------- 维护人 ------------ 变更内容 --------
 * 2020-07-31        Administrator             新增Person类
 * 2020-07-31        Administrator             增加sex属性
 */
public class PreviewActivity extends BaseActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_preview);

        String url = getIntent().getStringExtra("img_url");


        RelativeLayout relativeLayout = findViewById(R.id.relative_title);
        relativeLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        TextView tv_record = findViewById(R.id.tv_record);
        tv_record.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!TextUtils.isEmpty(url)){

                    DonwloadSaveImg.donwloadImg(PreviewActivity.this, Constants.MAIN_URL + url);

                }
            }
        });


        ImageView imageView = findViewById(R.id.iv_bg);
        RequestOptions placeholder = new RequestOptions().placeholder(R.mipmap.ic_error_loading);

        Glide.with(PreviewActivity.this).load( Constants.MAIN_URL +url).apply(placeholder).into(imageView);



    }
}
